from constants.constant_config import MAIN_WINDOW
from utils.program import Program

"""
登录
    注意：在设置中要把编码改成utf-8
"""
program = Program()
app = program.connect_program()


def login(username, password):
    # 切换到操作窗口
    win = app.window(title=MAIN_WINDOW).child_window(title="登录", control_type="Window")
    # 输入用户名和密码
    target_control = win.child_window(title="用户名")
    # 输入密码
    password_edit = program.set_text(target_control, password)
    # 输入用户名
    username_edit = program.set_text(password_edit, username)
    # 点击确定按钮
    target_control = win.child_window(title="确定 Enter", found_index=0)
    target_control.click_input()


if __name__ == '__main__':
    login("yhy", "123456")
